package com.co.ud.icehome.postservice;

import org.mule.RequestContext;
import org.mule.api.MuleMessage;
import org.mule.api.MuleEvent;

import com.co.ud.icehome.utils.enums.KeyMessage;
import com.co.ud.icehome.utils.enums.ProtocolIceHome;

public class UserSetting {

	private String address = "localhost";
	private String port = "2013";
	private MuleEvent event;
	
	public MuleMessage configurarUsuario(String src){
		
		//System.out.println(src.toString());
		//String msg="Chrystian Duarte Ramirez";
		//System.out.println(msg);
		
		event = RequestContext.getEvent();
		MuleMessage message = event.getMessage();
		if (src != null) {
			
			
			String user =ProtocolIceHome.getUser(src);
			System.out.println("el usuario es :"+user);
			// get hostname from username

			String sensorValue =ProtocolIceHome.getSensorValue(src);
			System.out.println("el sensor es :"+sensorValue);
			
			//this.address="arduproject.dyndns.org";
			
			message.setOutboundProperty("host", address);
			message.setOutboundProperty("port", port);
			message.setOutboundProperty("path", KeyMessage.HTTP_KEY_SENSOR.getMsg()+sensorValue);
			message.setPayload(src);
			
		} else {
			message = null;
			// response="No existe dispositivo";
		}
		return message;
		
	} 
}
